package cn.zc.student.service.service.impl;

import cn.tools.dozer.config.DozerUtils;
import cn.zc.student.entity.StudentAndClassify;
import cn.zc.student.entity.VO.StudentAndClassifyVO;
import cn.zc.student.service.mapper.StudentAndClassifyMapper;
import cn.zc.student.service.service.StudentAndClassifyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 学生所报名的学科 服务实现类
 * </p>
 *
 * @author keno
 * @since 2022-02-23
 */
@Service
public class StudentAndClassifyServiceImpl extends ServiceImpl<StudentAndClassifyMapper, StudentAndClassify> implements StudentAndClassifyService {
    @Resource
    private StudentAndClassifyMapper studentAndClassifyMapper;

    @Resource
    private DozerUtils dozerUtils;
    /**
     * 查询学生报名的学科
     * @param studentId
     * @return
     */
    @Override
    public List<StudentAndClassifyVO> findClassify(String studentId) {
        List<StudentAndClassify> studentAndClassifies = studentAndClassifyMapper.selectList(new QueryWrapper<StudentAndClassify>()
                .lambda()
                .eq(StudentAndClassify::getStudentId, studentId));

        return dozerUtils.mapList(studentAndClassifies, StudentAndClassifyVO.class);
    }
}
